﻿/*  Simple Set class for .net framework
    Copyright (C) 2011  Farid Bekran http://developer.ba-da.ir/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

	*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace SimpleSet
{
    /// <summary>
    /// Universe class instance holds the all possible values of sets.
    /// </summary>
    public class Universe
    {
        /// <summary>
        /// Holds main possible values of Sets in Hashtable
        /// </summary>
        private Hashtable UniverseValues = new Hashtable();
        /// <summary>
        /// Creates an instance of Universe with integer values from _lowerBand to _upperBand
        /// </summary>
        /// <param name="_lowerBand"></param>
        /// <param name="_upperBand"></param>
        public Universe(int _lowerBand, int _upperBand)
        {
            for (int i = _lowerBand; i <= _upperBand; i++)
            {
                UniverseValues.Add(i.ToString(), false);
            }
        }
        /// <summary>
        /// With this method we can creat an instance of Universe class with exact values of Possible values.
        /// </summary>
        /// <param name="_directValues"></param>
        public Universe(List<string> _directValues)
        {
            _directValues = _directValues.Distinct<string>().ToList<string>();
            foreach (string item in _directValues)
            {
                UniverseValues.Add(item, false);
            }
            
        }
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns></returns>
        public Hashtable Clone()
        {
            Hashtable temp = (Hashtable)this.UniverseValues.Clone();
            return temp;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns>string</returns>
        public override string ToString()
        {
            string temp = string.Empty;
            temp += "{ ";
            int count = 0;
            foreach (DictionaryEntry dicItemp in this.UniverseValues)
            {
                string colon = ", ";
                if (count == this.UniverseValues.Count - 1)
                {
                    colon = "";
                }
                temp += dicItemp.Key.ToString() + colon;
                count++;
            }
            temp += " }";
            return temp;
        }
    }
}
